<%@ LANGUAGE="VBSCRIPT" %>
<%'  ------------------------------------------------------------
  '  newpassword.asp 
  '  ------------------------------------------------------------
  '  VCS INFO:
  '  
  '  $Revision:   1.13  $
  '  $Date:   08 Oct 1998 16:05:32  $
  '  $Author:   rurman  $
  '  $Workfile:   newpassword.asp  $
  '  ------------------------------------------------------------
  '  All Rights Reserved.  Copyright (c) 1988-1998 FileNET Corp.
  '  ------------------------------------------------------------
  '%>
<!-- #include file="islogon.asp" -->

<%
'Pick up the old and new password
OldPassword = Request.Form("OldPassword")
NewPassword = Request.Form("NewPassword")

'Create a Library object and reattach the LogonID
LibraryLogonID = Session("LibraryLogonID")
set LibraryObj = Server.CreateObject("IDMObjects.Library")
LibraryObj.LogonID = LibraryLogonID


On Error Resume Next
LibraryObj.ChangePassword OldPassword, NewPassword, 0
if Len(Err.Description) = 0 then
    'If password is changed successfully
    Session("PASSWORDSTATUS") = ""

    if LibraryObj.SystemType = Application("idmSysTypeIS") then
        'Image Services requires a re-logon after password is changed
        LibraryName = LibraryObj.Name

        'Cleanup Prefetching
        if Application("SupportPrefetching") then
            Session("LocalCache").ClearPrefetchCandidates(Session("LocalCacheSession"))
        end if

        'Logoff
        LibraryObj.Logoff
        Application("LogonIDManager").RemoveLogonID LibraryLogonID
        Session("LibraryName") = ""
        Session("LibraryLabel") = ""
        Session("LibraryLogonID") = ""

        'Recreate a clean Library
        set LibraryObj = Server.CreateObject("IDMObjects.Library")

        'Set the Name, SystemType, and SessionManager
        LibraryObj.Name = LibraryName
        LibraryObj.SystemType = Application("idmSysTypeIS")
        LibraryObj.SessionManager = Application("SessionManager")

        'Now, try to logon using the new password
        On Error Resume Next
        LibraryObj.Logon Session("Username"), NewPassword, "", 0
        if Len(Err.Description) = 0 then
            'If logon successfully
            Session("LibraryLogonID") = LibraryObj.LogonID
            Session("LibraryName") = LibraryObj.Name
            Session("LibraryLabel") = LibraryObj.Label
            Application("LogonIDManager").AddLogonID LibraryObj.LogonID, LibraryObj.Name
        else
            'Logon failed
            Session("SystemName") = LibraryName
            Session("Username") = Username
            Session("Group") = ""
            Response.Redirect "logon.asp?Failed=1"
        end if
    end if

    'If password change is successful, redirect back to the Home page.
    Response.Redirect "home.asp"
else
    'If password change failed, redirect back to the Change Password page with proper
    'status for the user to retry.
    Response.Redirect "password.asp?Status=-1"
end if
%>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html">
<TITLE>Change Password</TITLE>
</HEAD>

<body bgcolor="#FFFFFF">

<%= OldPassword %><br>
<%= NewPassword %><br>

</BODY>
</HTML>
